/* Banner Slider */
jQuery(document).ready(function() {
    jQuery("#banner-slider").jcarousel({
        scroll: 1,
        visible: 3,
        initCallback: slider_initCallback,
        itemVisibleInCallback: {
            onBeforeAnimation: function(){
                $("#banner-slider-current").css({
                    'opacity':'0'
                });
            },
            onAfterAnimation: function(){
                $("#banner-slider-current").css({
                    'opacity':'1'
                });
            }
        },
        buttonNextHTML: null,
        buttonPrevHTML: null,
        wrap: 'both',
        auto: 10
    });
});
jQuery(document).ready(function() {
    jQuery("#banner-slider-current").jcarousel({
        scroll: 1,
        visible: 1,
        initCallback: slider_initCallback,
        itemVisibleInCallback: highlight,
        itemVisibleOutCallback: removehighlight,
        buttonNextHTML: null,
        buttonPrevHTML: null,
        wrap: 'both',
        auto: 10
    });
});
$(window).bind("load", function() {
    $("#banner-slider").css({
        position: "absolute",
        left: -(($("#banner-slider").width()-$("body").width())/2) + "px"
    });
});
var sliders = [];
function slider_initCallback(carousel) {
    sliders.push(carousel);
    carousel.clip.hover(function() {
        for(j=0;j<sliders.length;j++){
            sliders[j].stopAuto();
        }
    }, function() {
        for(j=0;j<sliders.length;j++){
            sliders[j].startAuto();
        }
    });
    jQuery('#slider-next').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('#slider-back').bind('click', function() {
        carousel.prev();
        return false;
    });
}
function highlight(carousel, obejctli, liindex, listate) {
    $('.jcarousel-control a:nth-child(' + liindex + ')').addClass("active");
}    
function removehighlight(carousel, obejctli, liindex, listate) {
    $('.jcarousel-control a:nth-child(' + liindex + ')').removeClass("active");
}
$("#slider").hover(function () {
    var itemWidth = $("#banner-slider-current").width();
    var height = $("#slider").height();
    var width = $("#slider").width();
    var m = $("#slider-next").width()/4;
    $("#slider-next").css({
        top: ((height-$("#slider-next").height()) /2)+"px",
        left: ((width-itemWidth)/2 +itemWidth - m) + "px"
    });
    $("#slider-back").css({
        top: ((height-$("#slider-back").height()) /2)+"px",
        right: ((width-itemWidth)/2 +itemWidth - m) + "px"
    });
    $("#slider-next").fadeIn("slow");
    $("#slider-back").fadeIn("slow");
},function () {
    $("#slider-next").fadeOut("slow");
    $("#slider-back").fadeOut("slow");
});
function bannerHandle_Scroll(){
    $("#banner-slider").css({
        position: "absolute",
        left: -(( $("#banner-slider").width()-$("body").width())/2) + "px"
    });
}
$(window).scroll(bannerHandle_Scroll).resize(bannerHandle_Scroll);
/* Categories Panel */
drawCategoryDock({
    mainNav: "#category-nav",
    controlBtn: "#category",
    subNav:"#category-sub-nav",
    config:{
        showBottom:247,
        currentBottom:50
    }
});
$(window).scroll(function(){
    drawCategoryDock({
        mainNav: "#category-nav",
        controlBtn: "#category",
        subNav:"#category-sub-nav",
        config:{
            showBottom:247,
            currentBottom:50
        }
    });
}).resize(function(){
    drawCategoryDock({
        mainNav: "#category-nav",
        controlBtn: "#category",
        subNav:"#category-sub-nav",
        config:{
            showBottom:247,
            currentBottom:50
        }
    });
});
$("#category").controlSubCategoryNav({
    mainNav: "#category-nav",
    subNav:"#category-sub-nav",
    config:{
        showBottom:247,
        currentBottom:50
    }
});